package com.yxj01;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileOutputStreamDemo02 {
    public static void main(String[] args) throws IOException {
        //FileOutputStream(String name);创建文件输出流以指定的名称写入文件
        FileOutputStream fos = new FileOutputStream("D:\\Ccode\\jdata-structure\\ByteStream9\\fos.txt");
        //new File(name);上面一行等同于下面这行
        //FileOutputStream fos1 =new FileOutputStream(new File("D:\\Ccode\\jdata-structure\\ByteStream9\\fos.txt"));

        //FileOutputStream(File file); 创建文件输出流以写入由指定的File对象表示的文件
        //File file = new File("D:\\Ccode\\jdata-structure\\ByteStream9\\fos.txt");
        //FileOutputStream fos2 = new FileOutputStream(file);
        //等同于上两行，1和2做的事情是一样的，用哪个都行
        //FileOutputStream fos2 = new FileOutputStream(new File("D:\\Ccode\\jdata-structure\\ByteStream9\\fos.txt"));

        //写文件 void write(int n); void write(byte[] b); void write(byte[] b,int off, int len);
        //byte[] b = {97,98,99,100};
        //byte[] getBytes();返回字符串对于的字节数组
        byte[] bys = "abcde".getBytes();

        fos.write(bys,1,4);

    }
}
